#pragma once
#ifndef GAME_H
#define GAME_H
#include "Player.h"
#include "PlayGenerator.h"
#include "PropChangeSupport.h"
#include "PropChangeEvent.h"
#include "PlayInfo.h"
#include "Deck.h"
namespace SHGame {
	using namespace System::Collections::Generic;
	using namespace System;

	public ref class Game
	{
	public:
		
		property Player^ Picker;
		property Player^ Partener;
		property int PickerPoints;
		property int DefenderPoints;
	private:
		PlayInfo ^info;
		bool wantHumanBury;
		long gamecount;
		bool playing;
		Dictionary<Player^, PlayGenerator^> ^ playgens;
		Dictionary<Player^, CardSet^> ^ hands;
		Dictionary<Player^, int>^ points;
		PropChangeSupport^ pcs;
		Trick^ trick;
		Deck^ deck;
		Player^ lead;
		EventHandler<PropChangeEvent^> ^handler, ^handlerEnd, ^handlerStart;

	public:
		Game(Player^);
		void HumanQ(Object^ src, PropChangeEvent^ pe);
		Trick^ getTrick();
		bool hasTrick();
		bool play(Card^);
		Card^ getCard(int);
		bool hasPlayed(int);
		//void reset(); 
		void Reset();
		CardSet^ getHand(Player^);
		void HumanPick();
		void HumanPass();
		int GetPoints(Player^);
		bool TookTrick(Player^);
		bool WantHumanBury();
		void HumanBury(Card^ c);

	private:
		// event handling
		void HandleNextPlay(Object^, PropChangeEvent^);
		void HandleEndTurn(Object^, PropChangeEvent^);
		void HandleStartTurn(Object^, PropChangeEvent^);
		void askForPicker();
		void Pickup(Player^);
		void AddPoints(Player^, int);
		bool IsPickTeam(Player^);
	};

}

#endif